
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 3
 * @Author : WangRuoyu 
 * @Date : 2023/5/10 15:15
 */

#include "iostream"
#include "cstring"
#include "algorithm"

using namespace std;

int main() {
    int n;
    cin >> n;
    int nums[n];

    for (int i = 0; i < n; ++i) {
        cin >> nums[i];
    }

    int res = 0;

    for (int i = 0; i < n; ++i) {
        int minValue = 50000;
        for (int j = i; j < n; ++j) {
            if (nums[j] < minValue) {
                minValue = nums[j];
            }
            res = max(res, (j - i + 1) * minValue);
        }
    }

    cout << res;

    return 0;
}